package reone.android.anytest.zhyProgressBar;


import android.os.Bundle;
import android.os.Handler;
import android.view.Menu;
import android.app.Activity;
import android.widget.TextView;

import reone.android.anytest.R;

public class ZhyProgressBarMainActivity extends Activity {

	private RoundProgressBarWidthNumber mRoundProgressBar;

	private HorizontalProgressBarWithNumber mProgressBar;

    private TextView showText;

	private static final int MSG_PROGRESS_UPDATE = 0x110;

	private Handler mHandler = new Handler() {
		public void handleMessage(android.os.Message msg) {
			int progress = mProgressBar.getProgress();
			int roundProgress = mRoundProgressBar.getProgress();
			mProgressBar.setProgress(++progress);
			mRoundProgressBar.setProgress(++roundProgress);
            showText.setText("progress = " + progress);
			if (progress >= 150) {
				mHandler.removeMessages(MSG_PROGRESS_UPDATE);
			}else{
                mHandler.sendEmptyMessageDelayed(MSG_PROGRESS_UPDATE, 100);
            }
		};
	};

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_zhy_progress_bar_main);
        showText = (TextView) findViewById(R.id.text_show);
		mProgressBar = (HorizontalProgressBarWithNumber) findViewById(R.id.id_progressbar01);
        mProgressBar.setMax(1000);
		mRoundProgressBar = (RoundProgressBarWidthNumber) findViewById(R.id.id_progress02);
        mRoundProgressBar.setMax(200);
		mHandler.sendEmptyMessage(MSG_PROGRESS_UPDATE);

	}
	
	@Override
	public boolean onCreateOptionsMenu(Menu menu)
	{
		getMenuInflater().inflate(R.menu.menu_main, menu);
		return true;
	}

}
